import java.util.Scanner;
import java.util.Stack;

public class MinStack {
    Stack<Integer> stack = new Stack<>();
    Stack<Integer> minStack = new Stack<>();

    public MinStack() {
        stack = new Stack<>();
        minStack = new Stack<>();
    }

    public void push(int val) {
        stack.push(val);
        if(minStack.empty()){
            minStack.push(val);
        }else{
            int peekMinVal = minStack.peek();
            if(val <= peekMinVal){
                minStack.push(val);
            }
        }
    }

    public void pop() {
        int val = stack.pop();
        if(val == minStack.peek()){
            minStack.pop();
        }
    }

    public int top() {
        return stack.peek();
    }

    public int getMin() {
        return minStack.peek();
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        MinStack minStack = new MinStack();
        while (true) {
            String command = in.next();
            if ("exit".equals(command)) {
                break;
            }

            switch (command) {
                case "push":
                    int val = in.nextInt();
                    minStack.push(val);
                    System.out.println("元素 " + val + " 已入栈");
                    break;
                case "pop":
                    if (!minStack.stack.empty()) {
                        minStack.pop();
                        System.out.println("栈顶元素已出栈");
                    } else {
                        System.out.println("栈为空，无法出栈");
                    }
                    break;
                case "top":
                    if (!minStack.stack.empty()) {
                        System.out.println("栈顶元素为：" + minStack.top());
                    } else {
                        System.out.println("栈为空，无栈顶元素");
                    }
                    break;
                case "getMin":
                    if (!minStack.minStack.empty()) {
                        System.out.println("当前栈的最小元素为：" + minStack.getMin());
                    } else {
                        System.out.println("栈为空，无最小元素");
                    }
                    break;
                default:
                    System.out.println("无效指令，请重新输入");
            }
        }
    }
}